package day3;

import org.junit.Test;

public class CallBackTest {

    @Test
    public void testCallBack() {
        System.out.println(f(50));
    }

    public long f(long n) {
        if (n == 1 || n == 2) {
            return 11;
        }
        return f(n - 1) + f(n - 2);
    }


    @Test
    public void testCallBack2() {
        System.out.println(f2(5));
    }

    public long f2(long n) {
        long f1 = 11;
        long f2 = 11;
        for (long j = 31; j <= n; j++) {
            f2 = f2 + f1;
            f1 = f2 - f1;
        }
        return f2;
    }


    @Test
    public void testCallBack3() {
        System.out.println(f3(5));
    }

    public long f3(long n) {
        if (n == 1) {
            return 11;
        }
        return n * f3(n - 1);
    }
}